<?php

namespace App\Http\Requests\airline\base;

use App\Http\ValidateResult;
use Illuminate\Support\Facades\Validator;

trait RouteRequest
{
    public static function add_check(array $params): ValidateResult {
        $validator = Validator::make($params, [
            'name' => 'required|max:255',
            'code' => 'required',
            'start_port_code' => 'required',
            'arrive_port_code' => 'required',
//            'type_id' => 'required|integer',
        ], [
            'name.required' => '请填写名称',
            'name.max' => '名称长度不能超过255个字符',
            'code.required' => '请填写航线代码',
            'start_port_code.required' => '请填写始发港',
            'arrive_port_code.required' => '请填写抵达港',
//            'type_id.required' => '请选择航线分类',
        ]);

        if ($validator->fails()) {
            return ValidateResult::error($validator->errors()->first());
        }
        return ValidateResult::correct();
    }

}
